package cn.hchaojie.javase.day08;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.chart.LineChart;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
//import javafx.scene.chart.XYChart.Series;
import javafx.scene.chart.XYChart.Data;
import javafx.scene.transform.Scale;
import javafx.stage.Stage;

public class LineChartDemo extends Application {
	public static void main(String[] args) {
		launch(args);
	}

	@Override
	public void start(Stage primaryStage) throws Exception {
		// 创建一个图表
		
		// 创建x轴
		NumberAxis xAxis = new NumberAxis("Values for X-Axis", 0, 3, 1);
		NumberAxis yAxis = new NumberAxis("Values for Y-Axis", 0, 3, 1);
		
		LineChart lineChart = new LineChart(xAxis, yAxis);
		
		// 坐标点的数据
		XYChart.Series series = new XYChart.Series<>();
//		series.getData().add(new XYChart.Data<>(0.0, 1.0));
//		series.getData().add(new XYChart.Data<>(1.0, 2.0));
//		series.getData().add(new XYChart.Data<>(1.2, 3.0));
//		series.getData().add(new XYChart.Data<>(3.0, 1.0));
		
		series.getData().add(new Data(0.0, 1.0));
		series.getData().add(new Data(1.0, 2.0));
		series.getData().add(new Data(1.2, 3.0));
		series.getData().add(new Data(3.0, 1.0));
		
		// 数据添加到图表
		lineChart.getData().add(series);
		
		
//		Series s = new Series<>();
		
		// 根据图表创建Scene场景
		Scene scene = new Scene(lineChart);
		
		// 场景添加到舞台
		primaryStage.setScene(scene);
		primaryStage.show();
	}
}
